﻿<UserControl
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:ViewModel="clr-namespace:WpfCardGame.ViewModel" 
             xmlns:Conv="clr-namespace:WpfCardGame.Converters" 
             x:Class="WpfCardGame.Views.WarView" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.DataContext>
        <ViewModel:WarViewModel/>
    </UserControl.DataContext>
    <UserControl.Resources>
        <BooleanToVisibilityConverter x:Key="BoolToVis" />
        <Conv:SuitToBackgroundConverter x:Key="SuitToBack" />
    </UserControl.Resources>
    <Grid>
        <Grid.Resources>
            <Style x:Key="MyLabels" TargetType="Label">
                <Setter Property="HorizontalAlignment" Value="Left"/>
                <Setter Property="VerticalAlignment" Value="Top"/>
            </Style>
            
        </Grid.Resources>
        
        
        <TextBlock Text="{Binding Name}">
        </TextBlock>
       
        <Label x:Name="lblDealer"
               Content="Dealer" 

               Margin="120,0,0,0">
        </Label>
        
        <Label x:Name="lblPlayer"
               Content="Player" 
               Background="{Binding game.playerHand.CardsOnHand[0].Suit, Converter={StaticResource SuitToBack}}"
               Style="{StaticResource MyLabels}"
               Margin="126,264,0,0"/>
       
        <Button x:Name="btnDeal"
                Content="Deal" 
                HorizontalAlignment="Left" 
                Margin="215,270,0,0" 
                VerticalAlignment="Top" 
                Width="75" 
                Command="{Binding DealCommand, Mode=OneWay}">
            <Button.Style>
                <Style TargetType="Button">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding game.playerHand.CardsOnHand[0].Suit}" Value="h">
                            <Setter Property="Background" Value="Red"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding game.playerHand.CardsOnHand[0].Suit}" Value="c">
                            <Setter Property="Background" Value="Beige"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Button.Style>
        </Button>
       
        <Button x:Name="btnPlayerMove" 
                Content="Next Card" 
                HorizontalAlignment="Left" 
                Margin="10,270,0,0" 
                VerticalAlignment="Top" 
                Width="75" 
                
                Command="{Binding PlayerMoveCommand, Mode=OneWay}"/>
 
        <Image x:Name="pbPCinPlay" 
               HorizontalAlignment="Left" 
               Height="69" 
               Margin="120,186,0,0" 
               VerticalAlignment="Top" 
               Width="44" 
               Source="{Binding game.playerHand.CardsOnHand[0].Image}" 
               Visibility="{Binding game.playerHand.CardsOnHand[0].FaceDown, Converter={StaticResource BoolToVis}}" />
        
        <Image x:Name="pbPPOW1" 
               HorizontalAlignment="Left" 
               Height="69" 
               Margin="240,186,0,0" 
               VerticalAlignment="Top" 
               Width="44"
               Source="{Binding game.playerHand.CardsOnHand[1].FDImage}" 
               Visibility="{Binding game.playerHand.CardsOnHand[1].FaceDown, Converter={StaticResource BoolToVis}}" />
        
        <Image x:Name="pbPPOW2" 
               HorizontalAlignment="Left" 
               Height="69" 
               Margin="230,176,0,0" 
               VerticalAlignment="Top" 
               Width="44"
               Source="{Binding game.playerHand.CardsOnHand[2].FDImage}" 
               Visibility="{Binding game.playerHand.CardsOnHand[2].FaceDown, Converter={StaticResource BoolToVis}}" />
        
        <Image x:Name="pbPPOW3" 
               HorizontalAlignment="Left" 
               Height="69" 
               Margin="220,166,0,0" 
               VerticalAlignment="Top" 
               Width="44"               
               Source="{Binding game.playerHand.CardsOnHand[3].FDImage}" 
               Visibility="{Binding game.playerHand.CardsOnHand[3].FaceDown, Converter={StaticResource BoolToVis}}" />
        
        <Image x:Name="pbPPOW4" 
               HorizontalAlignment="Left" 
               Height="69" 
               Margin="210,156,0,0" 
               VerticalAlignment="Top" 
               Width="44"               
               Source="{Binding game.playerHand.CardsOnHand[4].Image}" 
               Visibility="{Binding game.playerHand.CardsOnHand[4].FaceDown, Converter={StaticResource BoolToVis}}" />
             
        <Image x:Name="pbPCinDeck" 
               HorizontalAlignment="Left" 
               Height="69" 
               Margin="40,186,0,0" 
               VerticalAlignment="Top" 
               Width="44"               
               Source="{Binding game.playerHand.CardsOnHand[0].FDImage}" 
               Visibility="{Binding game.playerHand.CardsOnHand[0].FaceDown, Converter={StaticResource BoolToVis}}" />
        
        <Image x:Name="pbDCinPlay" 
               HorizontalAlignment="Left" 
               Height="69" 
               Margin="120,26,0,0" 
               VerticalAlignment="Top" 
               Width="44"               
               Source="{Binding game.dealerHand.CardsOnHand[0].Image}" 
               Visibility="{Binding game.dealerHand.CardsOnHand[0].FaceDown, Converter={StaticResource BoolToVis}}" />
        
        <Image x:Name="pbDPOW1" 
               HorizontalAlignment="Left" 
               Height="69" 
               Margin="10,26,0,0" 
               VerticalAlignment="Top" 
               Width="44"               
               Source="{Binding game.dealerHand.CardsOnHand[1].FDImage}" 
               Visibility="{Binding game.dealerHand.CardsOnHand[1].FaceDown, Converter={StaticResource BoolToVis}}" />
        
        <Image x:Name="pbDPOW2" 
               HorizontalAlignment="Left" 
               Height="69" 
               Margin="20,36,0,0" 
               VerticalAlignment="Top" 
               Width="44"               
               Source="{Binding game.dealerHand.CardsOnHand[2].FDImage}" 
               Visibility="{Binding game.dealerHand.CardsOnHand[2].FaceDown, Converter={StaticResource BoolToVis}}" />
        
        <Image x:Name="pbDPOW3" 
               HorizontalAlignment="Left" 
               Height="69" 
               Margin="30,46,0,0" 
               VerticalAlignment="Top" 
               Width="44"               
               Source="{Binding game.dealerHand.CardsOnHand[3].FDImage}" 
               Visibility="{Binding game.dealerHand.CardsOnHand[3].FaceDown, Converter={StaticResource BoolToVis}}" />
        
        <Image x:Name="pbDPOW4" 
               HorizontalAlignment="Left" 
               Height="69" 
               Margin="40,56,0,0" 
               VerticalAlignment="Top" 
               Width="44"               
               Source="{Binding game.dealerHand.CardsOnHand[4].Image}" 
               Visibility="{Binding game.dealerHand.CardsOnHand[4].FaceDown, Converter={StaticResource BoolToVis}}" />
        
        <Image x:Name="pbDCinDeck" 
               HorizontalAlignment="Left" 
               Height="69" 
               Margin="210,26,0,0" 
               VerticalAlignment="Top" 
               Width="44"               
               Source="{Binding game.dealerHand.CardsOnHand[0].FDImage}" 
               Visibility="{Binding game.dealerHand.CardsOnHand[0].FaceDown, Converter={StaticResource BoolToVis}}" />
        
        <TextBlock x:Name="tbPlayerCount" 
                   HorizontalAlignment="Left" 
                   Margin="35,163,0,0" 
                   TextWrapping="Wrap" 
                   Text="{Binding game.playerHand.CardsOnHand.Count}" 
                   VerticalAlignment="Top">
        </TextBlock>
        
        <TextBlock x:Name="tbDealerCount" 
                   HorizontalAlignment="Left" 
                   Margin="205,99,0,0" 
                   TextWrapping="Wrap" 
                   Text="{Binding game.dealerHand.CardsOnHand.Count}" 
                   VerticalAlignment="Top"/>


    </Grid>
</UserControl>
